package tronglv.gs.view;

import java.util.zip.Inflater;

import org.xmlpull.v1.XmlPullParser;

import com.example.paralletkill.R;


import android.content.Context;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.util.Xml;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.Button;
import android.widget.GridView;
import android.widget.HorizontalScrollView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.LinearLayout.LayoutParams;

public class ChucNangChonBan extends LinearLayout{
	private boolean check = false;
	private TextView tv_Title , tv_value;
	private Button bt_dongy , bt_huy;
	private ImageView iv_cuscb;
	private LinearLayout layout1,layout2,layout3;
	private RelativeLayout layout3_1,layout3_2;

	public ChucNangChonBan(Context context, AttributeSet attrs) {
		super(context, attrs);
		// TODO Auto-generated constructor stub
		this.context = context;
		init();
	}
	private Context context;
	LayoutParams layoutAll;
	private LinearLayout layout4;
	public ChucNangChonBan(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
		this.context = context;
		init();
	}
	
	public void init(){
		layout1 = new LinearLayout(this.context);
		layout1.setLayoutParams(new LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.MATCH_PARENT));
		HorizontalScrollView scroll = new HorizontalScrollView(context);
		
		layout2 = new LinearLayout(this.context);
		layout2.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
		layout2.setOrientation(LinearLayout.HORIZONTAL);
		
		scroll.addView(layout2);
		
		for (int i = 0; i < 10; i++) {
			if(10%3 == 0){
				layout3 = new LinearLayout(this.context);
				layout3.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
				layout3.setOrientation(LinearLayout.VERTICAL);
				layout3.setWeightSum(0.9f);
			}
			  LayoutInflater inflater = LayoutInflater.from(context);  
			  View v = inflater.inflate(R.layout.chonban_item, null);
			  ImageView iv1 = (ImageView)v.findViewById(R.id.iv_ic1);
			  ImageView iv2 = (ImageView)v.findViewById(R.id.iv_ic2);
			  ImageView iv_trandanh = (ImageView)v.findViewById(R.id.iv_trandanh);
			  layout3.addView(v);
			  layout2.addView(layout3);
		}
		
		layout1.addView(scroll);
//		layout3 = new LinearLayout(this.context);
//		layout3.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
//		
//		
//		layout1.setOrientation(LinearLayout.VERTICAL);
//		layout2.setOrientation(LinearLayout.HORIZONTAL);
//		layout2.setGravity(Gravity.CENTER_VERTICAL);
//		layout3.setOrientation(LinearLayout.HORIZONTAL);
//		layout3_1 = new RelativeLayout(this.context);
//		layout3_2 = new RelativeLayout(this.context);
//		layout3.setWeightSum(1.0f);
//		
//		LayoutParams layout = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
//		tv_Title = new TextView(this.context);
//		layout.setMargins(0, 0, 0, 0);
//		tv_Title.setLayoutParams(layout);
//		tv_Title.setText("tronglv mời bạn vào phòng 2, tiền cược là 700G. Bạn có đồng ý không?");
//		tv_Title.setTextColor(Color.WHITE);
//		tv_value = new TextView(this.context);
//		tv_Title.setTextSize(17);
//		tv_Title.setTypeface(null, Typeface.NORMAL);
//		tv_value.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
//		tv_value.setText("Từ chối lời mời");
//		tv_value.setTextColor(Color.WHITE);
//		tv_value.setTextSize(15);
//		iv_cuscb = new ImageView(this.context);
//		iv_cuscb.setLayoutParams(new LayoutParams(40, 40));
////		iv_cuscb.setImageResource(R.drawable.check);
//		iv_cuscb.setOnTouchListener(new OnTouchListener() {
//			
//			@Override
//			public boolean onTouch(View v, MotionEvent event) {
//				// TODO Auto-generated method stub
//				if(!check){
////					iv_cuscb.setImageResource(R.drawable.uncheck);
//					check = true;
//				}
//				else{
////					iv_cuscb.setImageResource(R.drawable.check);
//					check = false;
//				}
//				return false;
//			}
//		});
//		
//		RelativeLayout.LayoutParams lp1=new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
//		bt_dongy = new Button(context);
////		bt_dongy.setBackgroundResource(R.drawable.click);
//		bt_dongy.setText("Đồng ý");
//		bt_dongy.setTypeface(null, Typeface.BOLD);
//		bt_dongy.setTextColor(Color.WHITE);
//		lp1.addRule(RelativeLayout.CENTER_HORIZONTAL);
//		layout3_1.addView(bt_dongy, lp1);
//		
//		RelativeLayout.LayoutParams lp2=new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
//		bt_huy = new Button(context);
////		bt_huy.setBackgroundResource(R.drawable.click);
//		bt_huy.setText("Từ Chối");
//		bt_huy.setTypeface(null, Typeface.BOLD);
//		bt_huy.setTextColor(Color.WHITE);
//		lp2.addRule(RelativeLayout.CENTER_HORIZONTAL);
//		layout3_2.addView(bt_huy,lp2);
//		
//		layout2.addView(iv_cuscb);
//		layout2.addView(tv_value);
//		
//		layout3.addView(layout3_1, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 0.5f));
//		layout3.addView(layout3_2, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 0.5f));
//		
//		layout1.addView(tv_Title);
//		layout1.addView(layout2);
//		layout1.addView(layout3);
		this.addView(layout1);
	}

}
